import 'package:flutter/foundation.dart';

enum SharePlatform { WeiXin, WeiXinCircle, Sina }

class ShareBean {
  ///分享类型
  ///
  /// * 图片:image
  /// * 文本:text
  /// * 暂不支持-h5或小程序:web
  /// * 全文本-自定义:textAll
  String shareType;

  ///是否直接分享，不显示弹窗
  bool shareDirect;

  ///分享平台
  List<int> shareMediaList;

  //------------------------------图片:image------------------------------
  ///图片:image-分享图片
  String shareImageUrl;

  ///解决Android，Flutter截屏的图使用File会有问题
  bool switchFile;

  //------------------------------文本:text------------------------------
  ///文本:text-分享文本
  String shareText;

  ///分享面板标题
  String title;

  ///分享面板副标题 如:分享到 | 蛋壳不错，分享一波！
  String subTitle;

  ///分享标题 如:蛋壳公寓
  String shareTitle;

  ///分享内容 如:住蛋壳，有所居有好居
  String shareContent;

  /*ShareBean(
      {this.shareType,
      this.shareImageUrl,
      this.shareText,
      this.title,
      this.subTitle,
      this.shareTitle,
      this.shareContent,
      this.shareDirect,
      this.shareMediaList});*/

  ShareBean.shareWxText({
    @required this.shareText,
    this.shareDirect = false,
  }) {
    this.shareType = "text";
    this.shareMediaList = [SharePlatform.WeiXin.index];
  }

  ShareBean.shareWxImage({
    @required this.shareImageUrl,
    this.shareDirect = false,
    this.switchFile = false,
  }) {
    this.shareType = "image";
    this.shareMediaList = [SharePlatform.WeiXin.index];
  }

  ShareBean.shareWxTextAll({
    this.title,
    this.subTitle,
    this.shareTitle,
    this.shareContent,
    this.shareDirect = false,
  }) {
    this.shareType = "textAll";
    this.shareMediaList = [SharePlatform.WeiXin.index];
  }

  ShareBean.fromJson(Map<String, dynamic> json) {
    this.shareType = json['shareType'];
    this.shareImageUrl = json['shareImageUrl'];
    this.switchFile = json['switchFile'];
    this.shareText = json['shareText'];
    this.title = json['title'];
    this.subTitle = json['subTitle'];
    this.shareTitle = json['shareTitle'];
    this.shareContent = json['shareContent'];
    this.shareDirect = json['shareDirect'];

    List<dynamic> shareMediaListList = json['shareMediaList'];
    this.shareMediaList = new List();
    this
        .shareMediaList
        .addAll(shareMediaListList.map((o) => int.parse(o.toString())));
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['shareType'] = this.shareType;
    data['shareImageUrl'] = this.shareImageUrl;
    data['switchFile'] = this.switchFile;
    data['shareText'] = this.shareText;
    data['title'] = this.title;
    data['subTitle'] = this.subTitle;
    data['shareTitle'] = this.shareTitle;
    data['shareContent'] = this.shareContent;
    data['shareDirect'] = this.shareDirect;
    data['shareMediaList'] = this.shareMediaList;
    return data;
  }
}
